package com.aorise.shiro;

import com.aorise.utils.MD5Utils;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

/**
 * @Auther: zhouhao
 * @Date: 2019/4/26
 * @Description:自定义 密码验证类
 */
public class CustomCredentialsMatcher extends SimpleCredentialsMatcher {


    @Override
    public boolean doCredentialsMatch(AuthenticationToken authcToken, AuthenticationInfo info) {
        UsernamePasswordToken token = (UsernamePasswordToken) authcToken;
        String accountCredentials = (String) getCredentials(info);
        return MD5Utils.validPasswd(String.valueOf(token.getPassword()), accountCredentials);
    }
}